<?php
// inc/class/system.php
namespace smp;

use smp\Base;
use smp\Config;
use smp\Debug;
use smp\Database;

class System extends Base {

	// ClassProperties ->
	protected static $errno, $error, $trace, $errorpage;
	protected static $readonly = array('error', 'errno', 'trace', 'readonly', 'secret');
	protected static $secret = array('readonly', 'secret');

	// initialize ->
	public static function initialize() {
		static::setTrace('initialize');
		if(!Config::load()) {
			Debug::add(Config::error(), 'FATAL', Config::errno(), Config::trace());
			return false;
		}
		Debug::add('Config loaded!', 'DEBUG', 0, Config::trace());
	return true;
	}

	// shutdown ->
	public static function shutdown($type = NULL) {
		if(Debug::active()) {
			$type = 'DEBUG';
		}
		switch ($type) {
			case 'DEBUG':
				Database::close();
				Debug::closeLogfile();
				Debug::flush();
				break;
			case 'FATAL':
				Database::close();
				Debug::closeLogfile();
				// PageLoader -!
				break;
			default:
				Database::close();
				Debug::closeLogfile();
		}
		die();
	}

}

?>